import numpy as np

num_pic = 3195


# 通过图片名返回ID
def get_ID(Images_by_GlobalID,pic_name):
    for i in range(Images_by_GlobalID[:,].shape):
        if Images_by_GlobalID[i,0]==pic_name:
            return Images_by_GlobalID[i,1]

def get_row(pic_name,new_DataSet):
    for i in range(np.shape(new_DataSet)[0]):
        if pic_name==new_DataSet[i][0]:
            a=new_DataSet[i][:]
            return a

def  label_string_to_int(label_np):
    i=0
    size=label_np.size
    result=np.zeros(label_np.size,dtype=int)
    while(i<size):
        if label_np[i]=='Positive ID':
            result[i]=0
        if label_np[i] == 'Negative ID'or label_np[i]=='Unprocessed':
            result[i] = 1
        if label_np[i] == 'Unverified':
            result[i] = 2
        i=i+1
    return result#result是转换成int的标签
def label_one_hot(label_np):
    label_type=3
    label_onehot_np=np.zeros((num_pic))
    label_list=[]
    for i in range(num_pic):
        if label_np[i]=='Positive ID':
            #label_one_hot[i]=[1,0,0]
            label_list.append([1,0,0])

        if label_np[i]=='Negative ID' or label_np[i]=='Unprocessed':
            #label_one_hot[i]=[0,1,0]
            label_list.append([0,1,0])


        if label_np[i]=='Unverified':
            #label_one_hot[i]=[0,0,1]
            label_list.append([0,0,1])


    print(label_list)
    label_onehot_np=np.array(label_list)
    print(label_onehot_np)
    print(label_onehot_np.shape)
    return label_onehot_np

if __name__ == '__main__':
    np_test=np.array(['Positive ID','Negative ID'])
    label_np=label_string_to_int(np_test)
    print(label_np)
    print(type(label_np[1]))

